<?php
namespace App\Http\Controllers\Backend\Basic;

use App\Http\Controllers\Backend\BaseController;
use App\Http\Requests\Backend\Basic\CurrencyRequest;
use App\Repositories\PrtCurrencyRepository;

/**
 * 项目说明
 * 详细说明
 * @author:
 * @version: 1.0
 * @date:
 */
class CurrencyController extends BaseController
{
    protected $viewPath = 'backend.basic.currency';  //当前控制器所的view所在的目录
    protected $modules = 'sys';        //当前控制器所属模块
    protected $codePrefix = 'CUR';        //编码前缀
    public function __construct(PrtCurrencyRepository $Repository)
    {
        parent::__construct();
        $this->repositories = $Repository;
    }

   //添加/编辑操作
    public function save(CurrencyRequest $request)
    {
        $params = $request->all();
        $params['sys_code'] = $this->codePrefix;
        $userInfo = $this->getUserInfo();
        if (!$params['id']) {
            $params['creator_uid'] = $userInfo['id'];
        } else {
            $params['updater_uid'] = $userInfo['id'];
        }
        $ret = $this->repositories->save($params);
        if ($ret) {
            return $this->jsonSuccess([]);
        } else {
            return $this->jsonFailed('');
        }
    }

}
